from ..attributes import *

from .dialog import DialogController


class AbstractGUI(DialogController):
    primitive = Attribute()
    screen    = primitive._.screen
    
    title     = Attribute(changed = lambda self: self.primitive.set_title(self.title))
    size      = Attribute(changed = lambda self: self.primitive.set_frame_size(*self.size))
    
    def setup(self):
        super(AbstractGUI, self).setup()
        
        self.primitive.model = self
    
    def setup_primitive(self):
        self.primitive.setup_primitive()
    
    def update(self):
        self.update_dialogs()
    
    def run(self):
        self.primitive.run()
